home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / sun / volume1 / calctool / patch01 < prev    next >
Encoding:
Internet Message Format  |  1989-07-12  |  9.4 KB

  1. Path: uunet!cs.utexas.edu!tut.cis.ohio-state.edu!cica!iuvax!rutgers!aramis.rutgers.edu!dartagnan.rutgers.edu!mcgrew
  2. From: mcgrew@dartagnan.rutgers.edu (Charles Mcgrew)
  3. Newsgroups: comp.sources.sun
  4. Subject: v01i042:  Patch #1 to Calctool
  5. Message-ID: <Jul.12.16.07.54.1989.4792@dartagnan.rutgers.edu>
  6. Date: 12 Jul 89 20:07:58 GMT
  7. Organization: Rutgers Univ., New Brunswick, N.J.
  8. Lines: 186
  9. Approved: mcgrew@aramis.rutgers.edu
  10.  
  11. Submitted-by: chuck@trantor.harris-atd.com (Chuck Musciano)
  12. Posting-number: Volume 1, Issue 41
  13. Archive-name: calctool/patch01
  14.  
  15.      This patch fixes code which causes the C compiler on 386i machines
  16. to go into an infinite loop.  Apparently, the 386i compiler cannot handle
  17. casting (double *) to (unsigned int) in some cases.  
  18.  
  19.      If there are any problems with this patch, please let me know, since I
  20. do not have access to a 386i for testing purposes.
  21.  
  22. Chuck Musciano                ARPA  : chuck@trantor.harris-atd.com
  23. Harris Corporation             Usenet: ...!uunet!x102a!trantor!chuck
  24. PO Box 37, MS 3A/1912            AT&T  : (407) 727-6131
  25. Melbourne, FL 32902            FAX   : (407) 727-{5118,5227,4004}
  26.  
  27. Oh yeah, laugh now!  But when the millions start pouring in, I'll be the one
  28. at Burger King, sucking down Whoppers at my own private table! --Al Bundy
  29.  
  30. #! /bin/sh
  31. # This is a shell archive.  Remove anything before this line, then unpack
  32. # it by saving it into a file and typing "sh file".  To overwrite existing
  33. # files, type "sh file -c".  You can also feed this as standard input via
  34. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  35. # will see the following message at the end:
  36. #        "End of shell archive."
  37. # Contents:  patch
  38. # Wrapped by chuck@melmac on Tue Jul 11 11:17:07 1989
  39. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  40. if test -f 'patch' -a "${1}" != "-c" ; then 
  41.   echo shar: Will not clobber existing file \"'patch'\"
  42. else
  43. echo shar: Extracting \"'patch'\" \(7011 characters\)
  44. sed "s/^X//" >'patch' <<'END_OF_FILE'
  45. X*** ops.c.orig    Tue Jul 11 10:56:04 1989
  46. X--- ops.c    Tue Jul 11 11:07:49 1989
  47. X***************
  48. X*** 36,53 ****
  49. X  
  50. X  #define        low_order(b, x)        ((((unsigned) 0xffffffff) >> (32 - (b))) & (x))
  51. X  
  52. X  PRIVATE    pop_op()
  53. X  
  54. X  {    int    i, temp;
  55. X  
  56. X      if (curr_mode != SCIENTIFIC && o_stack[o_top - 1]) {
  57. X!        v_stack[v_top] = (double) low_order(curr_width[index_of(curr_base)], (unsigned int) v_stack[v_top]);
  58. X!        v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], (unsigned int) v_stack[v_top - 1]);
  59. X         }
  60. X      switch (o_stack[--o_top]) {
  61. X         case ADD_OP    : v_stack[v_top - 1] += v_stack[v_top];
  62. X                         break;
  63. X!        case AND_OP    : temp = ((unsigned int) v_stack[v_top - 1]) & ((unsigned int) v_stack[v_top]);
  64. X                         v_stack[v_top - 1] = (double) temp;
  65. X                         break;
  66. X         case DIV_OP    : v_stack[v_top - 1] /= v_stack[v_top];
  67. X--- 36,62 ----
  68. X  
  69. X  #define        low_order(b, x)        ((((unsigned) 0xffffffff) >> (32 - (b))) & (x))
  70. X  
  71. X+ /************************************************************************/
  72. X+ /*    In the following code, the apparently extraneous assignments    */
  73. X+ /* to vt1 and vt2 are used to circumvent a bug in the 386i C compiler    */
  74. X+ /* which hangs when trying to compile code which casts a (double *) to    */
  75. X+ /* (unsigned int).  Sigh...                        */
  76. X+ /************************************************************************/
  77. X+ 
  78. X+ PRIVATE    double    vt1, vt2;
  79. X+ 
  80. X  PRIVATE    pop_op()
  81. X  
  82. X  {    int    i, temp;
  83. X  
  84. X      if (curr_mode != SCIENTIFIC && o_stack[o_top - 1]) {
  85. X!        v_stack[v_top] = (double) low_order(curr_width[index_of(curr_base)], (unsigned int) (vt1 = v_stack[v_top]));
  86. X!        v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], (unsigned int) (vt2 = v_stack[v_top - 1]));
  87. X         }
  88. X      switch (o_stack[--o_top]) {
  89. X         case ADD_OP    : v_stack[v_top - 1] += v_stack[v_top];
  90. X                         break;
  91. X!        case AND_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) & ((unsigned int) (vt2 = v_stack[v_top]));
  92. X                         v_stack[v_top - 1] = (double) temp;
  93. X                         break;
  94. X         case DIV_OP    : v_stack[v_top - 1] /= v_stack[v_top];
  95. X***************
  96. X*** 54,86 ****
  97. X                         break;
  98. X         case LPAREN_OP : return;
  99. X                     break;
  100. X!        case LSL_OP    : temp = ((unsigned int) v_stack[v_top - 1]) << ((unsigned int) v_stack[v_top]);
  101. X                         v_stack[v_top - 1] = (double) temp;
  102. X                         break;
  103. X         case MUL_OP    : v_stack[v_top - 1] *= v_stack[v_top];
  104. X                         break;
  105. X!        case OR_OP     : temp = ((unsigned int) v_stack[v_top - 1]) | ((unsigned int) v_stack[v_top]);
  106. X                         v_stack[v_top - 1] = (double) temp;
  107. X                         break;
  108. X!        case ROL_OP    : for (i = (unsigned int) v_stack[v_top], temp = (unsigned int) v_stack[v_top - 1]; i; i--)
  109. X                        temp = (temp << 1) + ((((unsigned) temp) >> (curr_width[index_of(curr_base)] - 1)) & 1);
  110. X                     v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], temp);
  111. X                         break;
  112. X         case ROOT_OP   : v_stack[v_top - 1] = pow(v_stack[v_top - 1], 1.0 / v_stack[v_top]);
  113. X                         break;
  114. X!        case ROR_OP    : for (i = (unsigned int) v_stack[v_top], temp = (unsigned int) v_stack[v_top - 1]; i; i--)
  115. X                        temp = (((unsigned) temp) >> 1) + ((temp & 1) << (curr_width[index_of(curr_base)] - 1));
  116. X                     v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], temp);
  117. X                         break;
  118. X!        case RSA_OP    : temp = ((unsigned int) v_stack[v_top - 1]) >> ((unsigned int) v_stack[v_top]);
  119. X                         v_stack[v_top - 1] = (double) temp;
  120. X                         break;
  121. X!        case RSL_OP    : temp = ((unsigned int) ((unsigned int) v_stack[v_top - 1])) >> ((unsigned int) v_stack[v_top]);
  122. X                         v_stack[v_top - 1] = (double) temp;
  123. X                         break;
  124. X         case SUB_OP    : v_stack[v_top - 1] -= v_stack[v_top];
  125. X                         break;
  126. X!        case XOR_OP    : temp = ((unsigned int) v_stack[v_top - 1]) ^ ((unsigned int) v_stack[v_top]);
  127. X                         v_stack[v_top - 1] = (double) temp;
  128. X                         break;
  129. X         case Y2X_OP    : v_stack[v_top - 1] = pow(v_stack[v_top - 1], v_stack[v_top]);
  130. X--- 63,95 ----
  131. X                         break;
  132. X         case LPAREN_OP : return;
  133. X                     break;
  134. X!        case LSL_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) << ((unsigned int) (vt2 = v_stack[v_top]));
  135. X                         v_stack[v_top - 1] = (double) temp;
  136. X                         break;
  137. X         case MUL_OP    : v_stack[v_top - 1] *= v_stack[v_top];
  138. X                         break;
  139. X!        case OR_OP     : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) | ((unsigned int) (vt2 = v_stack[v_top]));
  140. X                         v_stack[v_top - 1] = (double) temp;
  141. X                         break;
  142. X!        case ROL_OP    : for (i = (unsigned int) (vt1 = v_stack[v_top]), temp = (unsigned int) (vt2 = v_stack[v_top - 1]); i; i--)
  143. X                        temp = (temp << 1) + ((((unsigned) temp) >> (curr_width[index_of(curr_base)] - 1)) & 1);
  144. X                     v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], temp);
  145. X                         break;
  146. X         case ROOT_OP   : v_stack[v_top - 1] = pow(v_stack[v_top - 1], 1.0 / v_stack[v_top]);
  147. X                         break;
  148. X!        case ROR_OP    : for (i = (unsigned int) (vt1 = v_stack[v_top]), temp = (unsigned int) (vt2 = v_stack[v_top - 1]); i; i--)
  149. X                        temp = (((unsigned) temp) >> 1) + ((temp & 1) << (curr_width[index_of(curr_base)] - 1));
  150. X                     v_stack[v_top - 1] = (double) low_order(curr_width[index_of(curr_base)], temp);
  151. X                         break;
  152. X!        case RSA_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) >> ((unsigned int) (vt2 = v_stack[v_top]));
  153. X                         v_stack[v_top - 1] = (double) temp;
  154. X                         break;
  155. X!        case RSL_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) >> ((unsigned int) (vt2 = v_stack[v_top]));
  156. X                         v_stack[v_top - 1] = (double) temp;
  157. X                         break;
  158. X         case SUB_OP    : v_stack[v_top - 1] -= v_stack[v_top];
  159. X                         break;
  160. X!        case XOR_OP    : temp = ((unsigned int) (vt1 = v_stack[v_top - 1])) ^ ((unsigned int) (vt2 = v_stack[v_top]));
  161. X                         v_stack[v_top - 1] = (double) temp;
  162. X                         break;
  163. X         case Y2X_OP    : v_stack[v_top - 1] = pow(v_stack[v_top - 1], v_stack[v_top]);
  164. X***************
  165. X*** 199,205 ****
  166. X                        break;
  167. X         case LOG_OP    : v_stack[v_top] = log10(v_stack[v_top]);
  168. X                        break;
  169. X!        case NOT_OP    : v_stack[v_top] = (double) low_order(curr_width[index_of(curr_base)], (~ (unsigned int) v_stack[v_top]));
  170. X                        break;
  171. X         case OVER_OP   : v_stack[v_top] = 1.0 / v_stack[v_top];
  172. X                        break;
  173. X--- 208,214 ----
  174. X                        break;
  175. X         case LOG_OP    : v_stack[v_top] = log10(v_stack[v_top]);
  176. X                        break;
  177. X!        case NOT_OP    : v_stack[v_top] = (double) low_order(curr_width[index_of(curr_base)], (~ (unsigned int) (vt1 = v_stack[v_top])));
  178. X                        break;
  179. X         case OVER_OP   : v_stack[v_top] = 1.0 / v_stack[v_top];
  180. X                        break;
  181. END_OF_FILE
  182. if test 7011 -ne `wc -c <'patch'`; then
  183.     echo shar: \"'patch'\" unpacked with wrong size!
  184. fi
  185. # end of 'patch'
  186. fi
  187. echo shar: End of shell archive.
  188. exit 0
  189.  
  190. Chuck Musciano                ARPA  : chuck@trantor.harris-atd.com
  191. Harris Corporation             Usenet: ...!uunet!x102a!trantor!chuck
  192. PO Box 37, MS 3A/1912            AT&T  : (407) 727-6131
  193. Melbourne, FL 32902            FAX   : (407) 727-{5118,5227,4004}
  194.  
  195. Oh yeah, laugh now!  But when the millions start pouring in, I'll be the one
  196. at Burger King, sucking down Whoppers at my own private table! --Al Bundy
  197.